﻿/*
最小的回文数 
Time Limit:1000MS  Memory Limit:32768K

  
	Description:
	给出一个数X，求比X大的最小的回文数！(x<10^20) 
	
	  Sample Input:
	  1
	  10
	  12
	  Sample Output:
	  2
	  11
	  22
*/
#include <stdio.h>
#include <string.h>
void panlindrome(char* num)
{
	
	size_t len=strlen(num);
	if (1==len)
	{
		if('9'==num[0])
			printf("11\n");
		else
			printf("%d\n", num[0]-'0'+1);
	}
	else
	{
		len>>=1;
		if(len&0x1)
			--len;
		if (num[len]<num[len+1])
			num[len]++;
		num[len+1]='\0';
		printf("%s%s\n", num, strrev(num));
	}
}
#define MAX_CHARS 32
int main()
{
	char num[MAX_CHARS]={0};
	while(EOF!=scanf("%s", num))
	{
		panlindrome(num);
	}
	return 0;
}
